#include "NumberDelegate.h"
#include <QLineEdit>

NumberDelegate::NumberDelegate(int type, QObject* parent)
    :QItemDelegate (parent)
    ,m_index(type)
{

}

QWidget *NumberDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QLineEdit* editor = new QLineEdit(parent);
    if(m_index == 0)
    {
        QIntValidator *validator = new QIntValidator(editor);
        editor->setValidator(validator);
    }
    else if(m_index == 1)
    {
        QDoubleValidator *validator = new QDoubleValidator(editor);
        editor->setValidator(validator);
    }
    return editor;
}
